@using Orientation = Radzen.Orientation
@inherits StudioComponentBase
<CascadingValue Value="this">
    <RadzenSplitter Orientation="Orientation.Horizontal">
        <RadzenSplitterPane Size="65%">

            <MudDynamicTabs @ref="@_dynamicTabs"
                            Style="height: 100%"
                            AddTab="@AddTabCallback"
                            CloseTab="@CloseTabCallback"
                            ActivePanelIndexChanged="OnActivePanelIndexChanged"
                            bind-ActivePanelIndex="@ActiveTabIndex"
                            AddIconToolTip="Click to open a new workflow tab" CloseIconToolTip="Close workflow"
                            Elevation="0"
                            ApplyEffectsToContainer>
                @foreach (var workflowInstance in WorkflowInstances)
                {
                    var definition = WorkflowDefinitions.First(x => x.Id == workflowInstance.DefinitionVersionId);
                    <MudTabPanel Text="@workflowInstance.Id" ShowCloseIcon="true" Style="height: 100%">
                        <WorkflowInstanceViewer
                            WorkflowInstance="workflowInstance" 
                            WorkflowDefinition="definition" 
                            PathChanged="PathChanged" 
                            ActivitySelected="ActivitySelected"
                            SelectedWorkflowExecutionLogRecord="SelectedWorkflowExecutionLogRecord"
                            />
                    </MudTabPanel>
                }

            </MudDynamicTabs>

        </RadzenSplitterPane>
        <RadzenSplitterPane Size="35%" Min="100px">
            <WorkflowInstanceDetails WorkflowInstance="@SelectedWorkflowInstance" WorkflowDefinition="SelectedWorkflowDefinition" />
        </RadzenSplitterPane>

    </RadzenSplitter>
</CascadingValue>